package com.example.dingdong.repository;

import java.util.Date;
import java.util.List;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import com.example.dingdong.daomain.MenuEntity;
import com.example.dingdong.daomain.OrderRecordEntity;
/**
 * 
 * @ClassName: OrderRecordRepository
 * @Description: 
 * @Author :chengwenixng
 * @DateTime 2022-03-25 22:33:20
 */
@Repository
public interface OrderRecordRepository extends JpaRepository<OrderRecordEntity,Long>{
	/**
	 * 
	 * @Title: findByDelFlag
	 * @Description: 
	 * @Author coding
	 * @DateTime 2022-03-25 22:33:15
	 * @param delFlag
	 * @return
	 */
	List<OrderRecordEntity> findByDelFlag(boolean delFlag);
	/**
	 * 
	 * @Title: findByIdAndDelFlag
	 * @Description: 
	 * @Author coding
	 * @DateTime 2022-03-25 23:33:47
	 * @param id
	 * @param delFlag
	 * @return
	 */
	OrderRecordEntity findByIdAndDelFlag(Long id,boolean delFlag);
	
	@Query(value = "SELECT date(cecking_in_time),COUNT(*) as number  FROM orderrecord_entity WHERE del_flag = TRUE and basic_user_entity_id= ?1 AND cecking_in_time BETWEEN ?2 AND ?3 GROUP BY date(cecking_in_time)", nativeQuery = true)
	List<Object[]> findOrderRecordInformation(Long id, Date startTime, Date endTime);
	/**
	 * 
	 * @Title: getTodayWarning
	 * @Description: 
	 * @Author coding
	 * @DateTime 2022-03-27 13:47:26
	 * @param startTime
	 * @param endTime
	 * @return
	 */
	@Query(value = "SELECT date(cecking_in_time),COUNT(*) as number  FROM  orderrecord_entity WHERE del_flag = TRUE and menu_entity_id= ?1 AND cecking_in_time BETWEEN ?2 AND ?3 GROUP BY date(cecking_in_time)", nativeQuery = true)
	List<OrderRecordEntity> getTodayOrder(Long id ,Date startTime, Date endTime);
	
	

}
